package com.bjwl.display.mapper.safty;

import com.bjwl.display.model.User;
import com.bjwl.display.vo.UserLoginVO;
import com.bjwl.display.vo.UserRegisterVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.Map;


public interface UserMapper {
    @Select("select * from sys_user where u_id=#{u_id}")
    User queryByuId(String u_id);

    @Select("select * from sys_user where u_id=#{u_id} and u_pwd=#{u_pwd}")
    User queryByuIdAnduPwd(UserLoginVO userLoginVO);

    //通过user id 查询role
    @Select("select ro_id from sys_ur where u_id=#{u_id}")
    Integer queryRoIdByUserId(String u_id);

    //添加用户
    @Insert("insert into sys_user values (#{u_id},#{u_name},#{u_pwd},DEFAULT)")
    @Options(useGeneratedKeys = true, keyProperty = "u_id", keyColumn = "u_id")
    boolean addUser(User user);

    //向sys_ur表中添加数据
    @Insert("insert into sys_ur(u_id,ro_id) values(#{u_id},#{ro_id})")
    boolean addrole(Map<String,Object> map);
}
